﻿using RockBus.DataContracts;
using System.ServiceModel;
using System.ServiceModel.Web;
using RockBus.DataContracts.ConfigurationService;

namespace RockBus.ConfigurationService.Interfaces
{
    [ServiceContract(Namespace = StringConstants.RockBusNamespace)]
    public interface IConfigurationService
    {
        //[OperationContract(Action = StringConstants.AddOrUpdateAction, ReplyAction = StringConstants.RockBusAckAction)]
        //RockBusAck AddOrUpdate(AddOrUpdatePublishersRequest publishersRequest, AddOrUpdateSubscribersRequest subscribersRequest);

        [OperationContract(Action = StringConstants.GetSubscriberConfigurationAction, ReplyAction = StringConstants.GetSubscriberConfigurationResponseAction)]
        [WebGet(UriTemplate = "/GetSubscriberConfiguration", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        SubscriberConfiguration GetSubscriberConfiguration();

        [OperationContract(Action = StringConstants.AddOrUpdateSubscribersAction, ReplyAction = StringConstants.RockBusAckAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/AddOrUpdateSubscribers", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        RockBusAck AddOrUpdateSubscribers(AddOrUpdateSubscribersRequest request);

        [OperationContract(Action = StringConstants.RemoveSubscribersAction, ReplyAction = StringConstants.RockBusAckAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/RemoveSubscribers", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        RockBusAck RemoveSubscribers(RemoveSubscribersRequest request);

        [OperationContract(Action = StringConstants.RemoveSubscriptionsAction, ReplyAction = StringConstants.RockBusAckAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/RemoveSubscriptions", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        RockBusAck RemoveSubscriptions(RemoveSubscriptionsRequest request);

        [OperationContract(Action = StringConstants.GetPublisherConfigurationAction, ReplyAction = StringConstants.GetPublisherConfigurationResponseAction)]
        [WebGet(UriTemplate = "/GetPublisherConfiguration", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        PublisherConfiguration GetPublisherConfiguration();

        [OperationContract(Action = StringConstants.AddOrUpdatePublishersAction, ReplyAction = StringConstants.AddOrUpdatePublishersResponseAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/AddOrUpdatePublishers", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        AddOrUpdatePublishersResponse AddOrUpdatePublishers(AddOrUpdatePublishersRequest request);

        [OperationContract(Action = StringConstants.RemovePublishersAction, ReplyAction = StringConstants.RockBusAckAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/RemovePublishers", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        RockBusAck RemovePublishers(RemovePublishersRequest request);

        [OperationContract(Action = StringConstants.RemoveReceivePortsAction, ReplyAction = StringConstants.RockBusAckAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/RemoveReceivePorts", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        RockBusAck RemoveReceivePorts(RemoveReceivePortsRequest request);

        [OperationContract(Action = StringConstants.RemoveAllSubscribersAction, ReplyAction = StringConstants.RockBusAckAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/RemoveAllSubscribers", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        RockBusAck RemoveAllSubscribers(RemoveAllSubscribersRequest request);

        [OperationContract(Action = StringConstants.RemoveAllPublishersAction, ReplyAction = StringConstants.RockBusAckAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/RemoveAllPublishers", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        RockBusAck RemoveAllPublishers(RemoveAllPublishersRequest request);

        [OperationContract(Action = StringConstants.GetInternalConfigurationAction, ReplyAction = StringConstants.GetInternalConfigurationResponseAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/GetInternalConfiguration", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        GetInternalConfigurationResponse GetInternalConfiguration(GetInternalConfigurationRequest request);

        [OperationContract(Action = StringConstants.SetInternalConfigurationAction, ReplyAction = StringConstants.RockBusAckAction)]
        [WebInvoke(Method = "POST", UriTemplate = "/SetInternalConfiguration", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
        RockBusAck SetInternalConfiguration(SetInternalConfigurationRequest request);
    }

    [ServiceContract(Namespace = StringConstants.RockBusNamespace)]
    public interface IConfigurationServiceOneWay
    {
        //[OperationContract(IsOneWay = true, Action = StringConstants.AddOrUpdateAction)]
        //void AddOrUpdate(AddOrUpdatePublishersRequest publishersRequest, AddOrUpdateSubscribersRequest subscribersRequest);

        [OperationContract(IsOneWay = true, Action = StringConstants.AddOrUpdateSubscribersAction)]
        void AddOrUpdateSubscribers(AddOrUpdateSubscribersRequest request);

        [OperationContract(IsOneWay = true, Action = StringConstants.RemoveSubscribersAction)]
        void RemoveSubscribers(RemoveSubscribersRequest request);

        [OperationContract(IsOneWay = true, Action = StringConstants.RemoveSubscriptionsAction)]
        void RemoveSubscriptions(RemoveSubscriptionsRequest request);

        [OperationContract(IsOneWay = true, Action = StringConstants.AddOrUpdatePublishersAction)]
        void AddOrUpdatePublishers(AddOrUpdatePublishersRequest request);

        [OperationContract(IsOneWay = true, Action = StringConstants.RemovePublishersAction)]
        void RemovePublishers(RemovePublishersRequest request);

        [OperationContract(IsOneWay = true, Action = StringConstants.RemoveReceivePortsAction)]
        void RemoveReceivePorts(RemoveReceivePortsRequest request);

        [OperationContract(IsOneWay = true, Action = StringConstants.RemoveAllSubscribersAction)]
        void RemoveAllSubscribers(RemoveAllSubscribersRequest request);

        [OperationContract(IsOneWay = true, Action = StringConstants.RemoveAllPublishersAction)]
        void RemoveAllPublishers(RemoveAllPublishersRequest request);

        [OperationContract(IsOneWay = true, Action = StringConstants.SetInternalConfigurationAction)]
        void SetInternalConfiguration(SetInternalConfigurationRequest request);
    }

    [ServiceContract(Namespace = StringConstants.RockBusNamespace)]
    public interface IListConfigurationService
    {
        [OperationContract(Action = StringConstants.GetSubscriberAction, ReplyAction = StringConstants.RockBusAckAction)]
        SubscriberInfo GetSubscriber(GetSubscriberRequest request);
    }
}
